package com.spark.core.transformation

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * flatMap 是一对多的关系
 * 处理一条数据得到多条数据结果
 */
object Demo3_flatMap {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setMaster("local").setAppName("flatMap")
    val sc = new SparkContext(conf)
    sc.setLogLevel("error")

    val infos: RDD[String] = sc.parallelize(Array[String]("hello spark", "hello hdfs", "hello hive"))

    val result: RDD[String] = infos.flatMap(_.split(" "))

    result.foreach(println)


  }
}
